/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * golongan.java
 *
 * Created on 30 Jun 11, 22:18:37
 */

package MasterData;

import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import koneksi.koneksi;

/**
 *
 * @author UserXP
 */
public class Golongan extends javax.swing.JInternalFrame {

    private DefaultTableModel dtm;
    private JTable table;
    private JTable tabelCari=null;
    koneksi config=new koneksi();

    private boolean inputValid() {
         boolean b;

            if(txtNama_golongan.getText().trim().equals("")){
                JOptionPane.showMessageDialog(jDialogGolongan, "Nama golongan masih kosong !");
                txtNama_golongan.requestFocus();
                b=false;
            }else if(txtKet_golongan.getText().trim().equals("")){
                JOptionPane.showMessageDialog(jDialogGolongan, "Keterangan golongan masih kosong !");
                b=false;
            
            }else{
             b=true;
            }
              return b;
            }
   
    public void tambah(){
        koneksi config=new koneksi();
        config.BuatKoneksiDB();
        try{
            Statement st=config.getConnection().createStatement();
            ResultSet cekkode=st.executeQuery("" +
                    "Select * from golongan where nama_golongan='"+txtNama_golongan.getText()+"'");
            if(cekkode.next()){
                JOptionPane.showMessageDialog(this, "Nama golongan Sudah Digunakan !!");
                txtNama_golongan.setText("");
                txtNama_golongan.requestFocus();
            }else{
            int tambahdata=st.executeUpdate(
                    "insert into golongan  values "+
                    "(null,'"+txtNama_golongan.getText()+"','"
                    +txtKet_golongan.getText()+"')");

            tampilTabel();
            if (tambahdata>0){
                JOptionPane.showMessageDialog(this, "Tambah data Sukses");
                
                txtNama_golongan.setText("");
                txtKet_golongan.setText("");
                txtNama_golongan.requestFocus();
            }
            }
           st.close();
        }catch(Exception e){
            JOptionPane.showMessageDialog(this, "Insert Data Gagal");
            e.printStackTrace();
        }


    }
    public void ubah(){
        koneksi config=new koneksi();
        config.BuatKoneksiDB();

        try{
            Statement st=config.getConnection().createStatement();
            int ubahdata=st.executeUpdate("" +
                    "update golongan set nama_golongan='"+txtNama_golongan.getText()+"', " +
                    "ket_golongan='"+txtKet_golongan.getText()+"' where nama_golongan="+
                    "'"+txtNama_golongan.getText()+"'");
            tampilTabel();
            if (ubahdata>0){
                txtNama_golongan.setText("");
                txtKet_golongan.setText("");
                txtKet_golongan.setText("");
                jDialogGolongan.setVisible(false);
                JOptionPane.showMessageDialog(this," Ubah data Sukses !");
            }
           st.close();
        }catch(Exception e){
            JOptionPane.showMessageDialog(this, "Update Data Gagal");
        }



    }
    public void hapus(){
        koneksi config=new koneksi();
        config.BuatKoneksiDB();

        try{
            Statement st=config.getConnection().createStatement();
            int hapusdata=st.executeUpdate("delete from golongan where nama_golongan='" +
                    ""+txtNama_golongan.getText()+"'");
            tampilTabel();
            if (hapusdata>0){
                jDialogGolongan.setVisible(false);
               
                txtNama_golongan.setText("");
                txtKet_golongan.setText("");
                
                txtKet_golongan.setText("");
                JOptionPane.showMessageDialog(this," Hapus data Sukses !");
            }
           st.close();
        }catch(Exception e){
            JOptionPane.showMessageDialog(this, "Hapus Data Gagal");
        }

    }
 private Object[][] getData(){
        Object[][] data1=null;
        try{
            Statement st=config.getConnection().createStatement();
            ResultSet rs=st.executeQuery(
                    "Select * from golongan ");
            rs.last();
            int rowCount=rs.getRow();
            rs.beforeFirst();
            data1=new Object[rowCount][3];
            int no=-1;
            while(rs.next()){
                no=no+1;
                data1[no][0]=rs.getString(1);
                data1[no][1]=rs.getString(2);
                data1[no][2]=rs.getString(3);
            }
            st.close();
        }catch(Exception e){
            JOptionPane.showMessageDialog(this, "Koneksi SQL Gagal Get Data");
        }
        return data1;
    }

    public void tampilTabel(){
        String[] columnNames={"Kode golongan","Nama","Keterangan"};
        table=new JTable();
        table.setModel(new DefaultTableModel(getData(),columnNames){
                boolean[] canEdit = new boolean[]{
                    false, false, false
                };
            @Override
                public boolean isCellEditable(int rowIndex, int columnIndex) {
                    return canEdit[columnIndex];
                }
        });
        jScrollPane1.setViewportView(table);

    }
    

   

     private Object[][] getDataCari(){
        Object[][] data1=null;
        try{
            String mcari=txtCari.getText();
            String fieldcari=jComboCari.getSelectedItem().toString();
            Statement st=config.getConnection().createStatement();
            ResultSet rs=st.executeQuery(
                    "Select * from golongan where "+fieldcari+
                            " like ('%"+mcari+"%')");
            rs.last();
            int rowCount=rs.getRow();
            rs.beforeFirst();
            data1=new Object[rowCount][3];
            int no=-1;
            while(rs.next()){
                no=no+1;
                data1[no][0]=rs.getString(1);
                data1[no][1]=rs.getString(2);
                data1[no][2]=rs.getString(3);
                
            }

            st.close();
        }catch(Exception e){
            JOptionPane.showMessageDialog(this, "Koneksi SQL Gagal");
        }
        return data1;
    }

    public void tampilTabelCari(){
       String[] columnNames={"Kode golongan","Nama","Keterangan"};
        table=new JTable();
        table.setModel(new DefaultTableModel(getDataCari(),columnNames){
                boolean[] canEdit = new boolean[]{
                    false, false, false
                };
            @Override
                public boolean isCellEditable(int rowIndex, int columnIndex) {
                    return canEdit[columnIndex];
                }
        });
        jScrollPane1.setViewportView(table);
         if(table.getRowCount()==0){
                JOptionPane.showMessageDialog(this,"Data Tidak Ditemukan ");
            }
    }
     private void showData(int row) {
        txtNama_golongan.setText(table.getValueAt(row, 1).toString());
        koneksi config=new koneksi();
        config.BuatKoneksiDB();
         try{
                 Statement st=config.getConnection().createStatement();
                 ResultSet rs=st.executeQuery("Select * from golongan where" +
                         " nama_golongan='"+txtNama_golongan.getText()+"'");
             if (rs.next()){
                
                 txtKet_golongan.setText(rs.getString(3));
                              rs.close();
              st.close();
             }
            }catch(Exception e){
                e.printStackTrace();
            }

   
    }

    private void clearTable(){
        table.removeAll();
    }

   
    public Golongan() {
        initComponents();
        config.BuatKoneksiDB();
        tampilTabel();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialogGolongan = new javax.swing.JDialog();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        btnOk = new javax.swing.JButton();
        btnTutupDialog = new javax.swing.JButton();
        txtNama_golongan = new com.uiMIF.JTextEx();
        txtKet_golongan = new com.uiMIF.JTextEx();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btnCari = new javax.swing.JButton();
        jComboCari = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        btnRefresh = new javax.swing.JButton();
        txtCari = new com.uiMIF.JTextEx();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel3 = new javax.swing.JPanel();
        btnTutup = new javax.swing.JButton();
        btnHapus = new javax.swing.JButton();
        btnUbah = new javax.swing.JButton();
        btnTambah = new javax.swing.JButton();

        jDialogGolongan.setTitle("Form Suplier");

        jLabel4.setText("Nama Golongan");

        jLabel6.setText("Keterangan");

        btnOk.setText("OK");
        btnOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkActionPerformed(evt);
            }
        });
        btnOk.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnOkKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                btnOkKeyTyped(evt);
            }
        });

        btnTutupDialog.setText("Tutup");
        btnTutupDialog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTutupDialogActionPerformed(evt);
            }
        });

        txtNama_golongan.setMaxlength(40);
        txtNama_golongan.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNama_golonganKeyTyped(evt);
            }
        });

        txtKet_golongan.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        txtKet_golongan.setMaxlength(40);
        txtKet_golongan.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtKet_golonganKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jDialogGolonganLayout = new javax.swing.GroupLayout(jDialogGolongan.getContentPane());
        jDialogGolongan.getContentPane().setLayout(jDialogGolonganLayout);
        jDialogGolonganLayout.setHorizontalGroup(
            jDialogGolonganLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogGolonganLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialogGolonganLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(jDialogGolonganLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(txtKet_golongan, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jDialogGolonganLayout.createSequentialGroup()
                        .addComponent(btnOk)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnTutupDialog))
                    .addComponent(txtNama_golongan, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jDialogGolonganLayout.setVerticalGroup(
            jDialogGolonganLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogGolonganLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jDialogGolonganLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtNama_golongan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jDialogGolonganLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtKet_golongan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jDialogGolonganLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnOk)
                    .addComponent(btnTutupDialog))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        setTitle("Form Golongan");

        jLabel1.setText("Masukkan Kata Kunci");

        btnCari.setText("Cari");
        btnCari.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCariActionPerformed(evt);
            }
        });
        btnCari.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                btnCariKeyTyped(evt);
            }
        });

        jComboCari.setMaximumRowCount(2);
        jComboCari.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "nama_golongan", "kode_golongan" }));
        jComboCari.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jComboCariKeyTyped(evt);
            }
        });

        jLabel2.setText("Pilih Jenis Kunci");

        btnRefresh.setText("Refresh");
        btnRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshActionPerformed(evt);
            }
        });

        txtCari.setMaxlength(15);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(txtCari, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jComboCari, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCari)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnRefresh))
                    .addComponent(jLabel2))
                .addContainerGap(79, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboCari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCari)
                    .addComponent(btnRefresh)
                    .addComponent(txtCari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel2.setLayout(new java.awt.BorderLayout());
        jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        btnTutup.setText("Tutup ");
        btnTutup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTutupActionPerformed(evt);
            }
        });

        btnHapus.setText("Hapus ");
        btnHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHapusActionPerformed(evt);
            }
        });

        btnUbah.setText(" Ubah ");
        btnUbah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUbahActionPerformed(evt);
            }
        });

        btnTambah.setText("Tambah");
        btnTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTambahActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(210, Short.MAX_VALUE)
                .addComponent(btnTambah)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnUbah)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnHapus)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnTutup)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnTutup)
                    .addComponent(btnHapus)
                    .addComponent(btnUbah)
                    .addComponent(btnTambah))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnTutupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTutupActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_btnTutupActionPerformed

    private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTambahActionPerformed
        // TODO add your handling code here:
       
        txtNama_golongan.setText("");
        txtKet_golongan.setText("");
        txtNama_golongan.setEditable(true);
        txtKet_golongan.setEditable(true);
        txtKet_golongan.setEditable(true);
        jDialogGolongan.setSize(300, 200);
        jDialogGolongan.setLocationRelativeTo(null);
        jDialogGolongan.setTitle(" Tambah Data golongan");
        btnOk.setText("Tambah");
        txtNama_golongan.setEditable(true);
        txtNama_golongan.requestFocus();
        jDialogGolongan.setVisible(true);
    }//GEN-LAST:event_btnTambahActionPerformed

    private void btnUbahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUbahActionPerformed
        // TODO add your handling code here:
         if(table.getSelectedRow()<0){

            JOptionPane.showMessageDialog(null, "Silahkan Pilih Data yang akan dirubah !");
        }else{
        
        showData(table.getSelectedRow());
        jDialogGolongan.setSize(300, 200);
        jDialogGolongan.setLocationRelativeTo(null);
        jDialogGolongan.setTitle(" Ubah Data golongan");
        btnOk.setText("Ubah");
        
        txtNama_golongan.setEditable(false);
        
        txtKet_golongan.setEditable(true);
       
        txtKet_golongan.setEditable(true);
        txtNama_golongan.requestFocus();
        jDialogGolongan.setVisible(true);
        txtNama_golongan.requestFocus();
       
        }
       
    }//GEN-LAST:event_btnUbahActionPerformed

    private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
        // TODO add your handling code here:
        if(btnOk.getText().equals("Tambah")){
            if(inputValid()){
               tambah();
                }
        }else if(btnOk.getText().equals("Ubah")){
            if(inputValid()){
                ubah();
                }
        }else if(btnOk.getText().equals("Hapus")){
            hapus();
        }
    }//GEN-LAST:event_btnOkActionPerformed

    private void btnTutupDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTutupDialogActionPerformed
        // TODO add your handling code here:
        txtNama_golongan.setText("");
        txtKet_golongan.setText("");
        txtKet_golongan.setText("");
        jDialogGolongan.setVisible(false);
        
    }//GEN-LAST:event_btnTutupDialogActionPerformed

    private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHapusActionPerformed
        // TODO add your handling code here:.
        if(table.getSelectedRow()<0){
            JOptionPane.showMessageDialog(null, "Silahkan Pilih Data yang akan dihapus !");
        }else{
        
        showData(table.getSelectedRow());
        jDialogGolongan.setSize(300, 200);
        jDialogGolongan.setLocationRelativeTo(null);
        jDialogGolongan.setTitle("Hapus Data");
        btnOk.setText("Hapus");
     
        txtNama_golongan.setEditable(false);
        
        txtKet_golongan.setEditable(false);
        
        txtKet_golongan.setEditable(false);
        jDialogGolongan.setVisible(true);

        }
    }//GEN-LAST:event_btnHapusActionPerformed

    private void btnCari(){
        if(txtCari.getText().equals("")){
            JOptionPane.showMessageDialog(this, "Silahkan Masukkan Kata Kunci !");
            txtCari.requestFocus();
        }else{
        tampilTabelCari();
        }
    }
    private void btnCariActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCariActionPerformed
        // TODO add your handling code here:
        btnCari();
    }//GEN-LAST:event_btnCariActionPerformed

    private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshActionPerformed
        // TODO add your handling code here:
        tampilTabel();
    }//GEN-LAST:event_btnRefreshActionPerformed

    private void txtNama_golonganKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNama_golonganKeyTyped
        // TODO add your handling code here:
        if(evt.getKeyChar()==evt.VK_ENTER)
            txtKet_golongan.requestFocus();
    }//GEN-LAST:event_txtNama_golonganKeyTyped

    private void txtKet_golonganKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtKet_golonganKeyTyped
        // TODO add your handling code here:
        if(evt.getKeyChar()==evt.VK_ENTER)
            btnOk.requestFocus();
    }//GEN-LAST:event_txtKet_golonganKeyTyped

    private void btnOkKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnOkKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnOkKeyPressed

    private void btnOkKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnOkKeyTyped
        // TODO add your handling code here:
        if(evt.getKeyChar()==evt.VK_ENTER){
            if(btnOk.getText().equals("Tambah")){
            if(inputValid()){
               tambah();
                }
        }else if(btnOk.getText().equals("Ubah")){
            if(inputValid()){
                ubah();
                }
        }else if(btnOk.getText().equals("Hapus")){
            hapus();
        }
        }

    }//GEN-LAST:event_btnOkKeyTyped

    private void jComboCariKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jComboCariKeyTyped
        // TODO add your handling code here:
        if(evt.getKeyChar()==evt.VK_ENTER)
            btnCari.requestFocus();
    }//GEN-LAST:event_jComboCariKeyTyped

    private void btnCariKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnCariKeyTyped
        // TODO add your handling code here:
        btnCari();
    }//GEN-LAST:event_btnCariKeyTyped


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCari;
    private javax.swing.JButton btnHapus;
    private javax.swing.JButton btnOk;
    private javax.swing.JButton btnRefresh;
    private javax.swing.JButton btnTambah;
    private javax.swing.JButton btnTutup;
    private javax.swing.JButton btnTutupDialog;
    private javax.swing.JButton btnUbah;
    private javax.swing.JComboBox jComboCari;
    private javax.swing.JDialog jDialogGolongan;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private com.uiMIF.JTextEx txtCari;
    private com.uiMIF.JTextEx txtKet_golongan;
    private com.uiMIF.JTextEx txtNama_golongan;
    // End of variables declaration//GEN-END:variables

}
